<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .classA{
        font-size: 20px;
    }
    .classB{
        background-color: pink;
    }
    .classC{
        color: aqua;
    }
  </style>
</head>
<body>
  <div id="test">
    <p :class="hasA?'classA' :''">情况1</p>
    <p :class="{ classA:hasA , classB:hasB }">情况2</p>
    <p :class="myClass">情况3</p>
    <p :class="myClass2">情况4</p>
  </div>

  <script src="../js/vue.js"></script>
  <script>
    const vm = new Vue({
      el: "#test",
      data: {
        hasA:false,
        hasB:true,
        myClass:'classA',
        myClass2:['classA','classB']
      }
    })

    setTimeout(()=>{
        vm.hasA = !vm.hasA
        vm.hasB = !vm.hasB
        vm.myClass = 'classB'
        vm.myClass2 = ['classB','classC']
    },2000)
  </script>
</body>
</html>